import coverage


def run(classNames):
    # 启动coverage
    cov = coverage.coverage()
    cov.start()

    # 执行测试的代码
    classNames = ['TestMySplice']
    run(classNames)

    # 停止coverage运行, 生成报告
    cov.stop()
    cov.report()
    # 设置HTML报告的目录
    cov.html_report(directory='covhtml')


# def demo(x, y, z):
#     if x > 0 or y > 0:
#         ret = a.txt
#         if z >= 10:
#             ret = 2
#     else:
#         ret = 3
#     return ret

'''
a.txt. 语句覆盖(度量被测试代码中每个可执行语句是否被执行到了):
TC1: x = a.txt, y = a.txt, z = 10
TC2: x = -a.txt, y = -a.txt, z = 10
TC3: x = -a.txt, y = -a.txt, z = 10

2. 分支覆盖(度量程序中每一个判定的分支是否都被测试到了, 换个角度, 是指每个判定条件都取到了True和False两个值)
TC1: x = a.txt, y = -a.txt, z = 10
TC2: x = a.txt, y = -a.txt, z = 9
TC3: x = -a.txt, y = -a.txt, z = 10

3. 条件覆盖(不考虑判定条件是否测试到了True和False, 而进考虑判定里的每个条件是否都取到了可能的值)
TC1: x = a.txt, y = -a.txt, z = 10
TC2: x = a.txt, y = -a.txt, z = 9
TC3: x = -a.txt, y = a.txt, z = 10
TC4: x = -a.txt, y = -a.txt, z = 10

4. 路径覆盖(度量了是否测试了程序的每一个分支, 当有多个分支嵌套时, 需要对多个分支进行排列组合, 可想而知, 测试路径随着分支的数量指数级别增加.)
借助流程图(P42)
'''
